function count_same_elements(collection) {
  //在这里写入代码
  var obj = {}
  for (let item of collection) {
    if(item.length>1){
      obj[item.substring(0,1)]=+item.replace(/[^0-9]/ig,"")
    }else{if (obj[item]) {
      obj[item]++;
    } else {
      obj[item] = 1;
    }
  }
  }
  var result = []
  for (let key in obj) {
    let temp = {}
    temp.key = key;
    temp.count = obj[key];
    result.push(temp)
  }
  return result;
}

module.exports = count_same_elements;
